#!/user/bin/env python
# -*- coding: utf-8 -*-
''' 
Author: Sjy
LastEditTime: 2024-12-17 10:21:47
Description: 提供快速界面对话框
'''

__all__= []

from PyQt5 import QtWidgets

def get_item(title, label:str="", options:list=[], parent=None, read=False, current=0) -> str:
    """弹出仅带有选择的对话框
    Args:
        parent (_type_, optional): 绑定主界面. Defaults to None.
        title (_type_): 对话框标题
        label (str, optional): 选择的标题. Defaults to "".
        options (dict, optional): 提供的选项，注意是个list. Defaults to [].

        current (int, optional): 当前选项. Defaults to 0.
        read:(bool, optional): 是否只读. Defaults to False.  false 为可编辑， true 为只读
        当最后一个参数为 True 时，表示对话框是只读的，用户只能从列表中选择项，无法手动输入其他内容。


    Returns:
        str: _description_
    """
    # 增加选择文本的通用对话框
    item, ok = QtWidgets.QInputDialog.getItem(parent, title or '选择', label or '选择数据:', options, current, read)
    if ok:return item
    return None
    
# getText() getInt() getDouble() getMultiLineText()
    




if __name__ == "__main__":
    def test_select():
        """测试选择对话框"""
        items = ["Spring", "Summer", "Fall", "Winter"]
        item, ok =get_item("QInputDialog::getItem()", "Season:", items, 0, False)
        if ok and item:
            print("item:", item)

            

    test_select()